package org.usfirst.frc.team1322.robot.commands;

import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc.team1322.robot.Robot;

/**
 *
 */
public class DriveToPosition extends Command {
	
	double tLocation;
    public DriveToPosition(double mLoc) {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
    	requires(Robot.driveSystem);
    	tLocation = mLoc;
    	Robot.driveSystem.setPos(tLocation);
    }
    
    public DriveToPosition(double mLoc, boolean mReset){
    	requires(Robot.driveSystem);
    	tLocation = mLoc;
    	Robot.driveSystem.resetEncoders();
    	Robot.driveSystem.setPos(tLocation);
    	Robot.driveSystem.enableClosedLoop();
    }

    // Called just before this Command runs the first time
    protected void initialize() {
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
    	if (Robot.driveSystem.isDone()){
    		this.isFinished();
    	}
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return true;
    }

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
